package feifei.cookie;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/cookie1.action")
public class CookieServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setContentType("text/html,charset=UTF-8");
       String username="feifei";
       String password="123456";
        Cookie cookie = new Cookie("username",username);
        resp.addCookie(cookie);
        //资源跳转
        resp.sendRedirect(req.getContextPath()+"/cookieInfo.html");
    }
}
